package com.education.expenses.facade;

import com.education.expenses.common.dto.ApproverReportsDTO;
import com.education.expenses.common.dto.GridDTO;
import com.education.expenses.eao.ReportEAO;
import com.education.expenses.entity.Report;
import com.education.expenses.entity.ReportStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Set;

/**
 * User: Егор
 * Date: 15.08.12
 * Time: 14:51
 */
@Service
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public class ReportFacade {
   @Autowired
   private ReportEAO reportEAO;

   public GridDTO<ApproverReportsDTO> getGridReports(Integer userId,
                                                     Date date,String status){
      List<Report> reports = reportEAO.getWeekReportsByStatus(userId,date,status);
      GridDTO<ApproverReportsDTO> gridDTO = new GridDTO<ApproverReportsDTO>();
      return gridDTO;
   }


   public void changeStatus(Integer id,ReportStatus status){
       Report report=reportEAO.getById(id.longValue());
       report.setReportStatus(status);
   }

   public void updateExpenses(Integer id, Long lodging, Long meals,
                              Long transportation,Long personal,Long misc){
      Report report = reportEAO.getById(id.longValue());
      report.setLodging(lodging);
      report.setMeals(meals);
      report.setTransportation(transportation);
      report.setPersonal(personal);
      report.setMisc(misc);
   }
}
